package com.lixin.smartclassroom.ui.home.tab3.activity

import android.annotation.SuppressLint
import android.os.Handler
import android.view.View
import com.drake.brv.utils.bindingAdapter
import com.drake.net.utils.scopeNetLife
import com.lixin.smartclassroom.api.getmyhuizhanglist
import com.lixin.smartclassroom.api.getzhutitype
import com.lixin.smartclassroom.api.huizhanglist
import com.lixin.smartclassroom.api.huodehuizhanglist
import com.lixin.smartclassroom.api.renwupllist
import com.lixin.smartclassroom.bean.DataListBean
import com.lixin.smartclassroom.databinding.ActivitySealBinding
import com.lixin.smartclassroom.ui.home.adapter.imgList
import com.lixinkeji.base.BaseActivity
import com.lixinkeji.extension.getIntentString
import com.lixinkeji.extension.gone
import com.lixinkeji.extension.onClick
import com.lixinkeji.extension.toast
import com.lixinkeji.extension.visible
import com.lixinkeji.utils.BitmapUtils

/**
 * Description 我的集章
 * Author: lwc
 * Date:2023/12/13 18:15
 */
class SealAct : BaseActivity<ActivitySealBinding>() {
    override fun getViewBinding() = ActivitySealBinding.inflate(layoutInflater)

    override fun topBarHide() = true
    override fun startPadding() = false
    private var taskType = ""
    private lateinit var listBean: ArrayList<DataListBean>

    override fun iniView() {
        taskType = getIntentString("type")
        listBean = ArrayList()
        binding.apply {
            recycler.imgList(1)
            refresh.onRefresh {
                scopeNetLife {
                    listBean = huodehuizhanglist()!!
                    addData(listBean) {
                        if (binding.recycler.bindingAdapter.models?.size == 0) {
                            binding.state.showEmpty()
                            binding.recycler.gone()
                        } else {
                            binding.recycler.visible()
                        }
                        listBean.size == 10
                    }
                }
            }.autoRefresh()
        }





    }

    override fun onClick() {
        binding.apply {

            ivBack.onClick {
                finish()
            }

            btnSure.onClick {
                Handler().postDelayed({
                    BitmapUtils.convertViewToBitmap(rlSeal, this@SealAct)
                    toast("保存成功！")
                }, 1000)

            }
        }
    }

}